package com.example.testProject.controller;

import com.example.testProject.domain.qo.user.AddQo;
import com.example.testProject.domain.qo.user.ListQo;
import com.example.testProject.domain.vo.user.ListVo;
import com.example.testProject.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户模块控制器
 *
 * @author czx
 * @date 2022/9/23 16:55
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @PostMapping("/list")
    public ListVo doList(@RequestBody @Validated ListQo listQo) {
        ListVo listVo = userService.doList(listQo);
        return listVo;
    }

    @PostMapping("/add")
    public int doAdd(@RequestBody @Validated AddQo addQo) {
        int row = userService.doAdd(addQo);
        return row;
    }
}
